<!--
 * @Description: 签约收款
 -->
<template>
  <div>
    <template v-if="listTotal > 0">
      <div class="signRecord" v-for="signedItem in noSignedList" :key="signedItem.srId">
        <div class="signTitle">签约信息</div>
        <div class="signInfo">您有一条来自<span>{{signedItem.companyName}}</span>的签约邀请</div>
        <van-button type="info" :url="signedItem.signUrl || signedItem.signShortUrl" block size="small">去签约</van-button>
      </div>
      <van-cell-group title="历史签约" v-if="signedList.length">
        <van-cell v-for="signedItem in signedList"
        :key="signedItem.id"
        :title="signedItem.companyName"
        is-link
        :url="signedItem.signUrl || signedItem.signShortUrl" />
      </van-cell-group>
    </template>
    <van-empty v-else-if="listTotal == 0" description="暂无签约内容～" />
    <van-empty v-else-if="listTotal == -1" image="error" description="获取记录出错" />
  </div>
</template>

<script>
import { checkSignRecord } from '@/api/check'
import { Toast } from 'vant'
export default {
  data () {
    return {
      signedList: [],
      noSignedList: [],
      listTotal: null
    }
  },
  methods: {

  },
  // 生命周期 - 创建完成（访问当前this实例）
  created () {
    const $this = this
    Toast.loading({
      forbidClick: true,
      duration: 0
    })
    // const $this = this
    checkSignRecord(1, 50).then(res => {
      console.log('checkSignRecord', res)
      Toast.clear()
      let signRecords = res.data.data.list
      $this.listTotal = res.data.data.total
      $this.signedList = signRecords.filter(function (item) {
        return item.signedStatus === 2
      })
      $this.noSignedList = signRecords.filter(function (item) {
        return item.signedStatus === 1
      })
      console.log('SIGNCOUNT', $this.noSignedList.length)
      localStorage.setItem('SIGNCOUNT', $this.noSignedList.length)
    }).catch(() => {
      Toast.clear()
      $this.listTotal = -1
    })
  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted () {

  }
}
</script>
<style scoped>
/* @import url(); 引入css类 */
.signRecord{
  width: 95%;
  height: 140px;
  margin: 10px auto 0;
  padding: 10px 15px;
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 5px;
  box-shadow: 0px 2px 3px #00000066;
  text-align: center;
  color: #333333;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.signTitle{
  font-size: 14px;
}
.signInfo{
  font-size: 16px;
}
.signInfo span{
  color: #101010;
}
.signRecord button{
  width: 110px;
  border-radius: 5px;
  margin: 0 auto;
}
.van-cell__title{
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>
